﻿using System;
using CompactMapper.Orm.Annotations;

namespace CompactMapper.Orm.UnitOfWork.Mappings.Meta.PropertyInfos.Relations
{
    internal class HasAndBelongsToMany : Relation
    {
        private readonly HasAndBelongsToManyAttribute _attribute;
        private readonly String _tableName;

        public HasAndBelongsToMany(PropertyInfoPersistenceAttributePair pair)
            : base(pair.PropertyInfo)
        {
            _attribute = (HasAndBelongsToManyAttribute) pair.PersistenceAttribute;
            _tableName = GetSomethingToManyTableName();
        }


        public HasAndBelongsToManyAttribute HasAndBelongsToManyAttribute
        {
            get { return _attribute; }
        }

        public override string TableName
        {
            get { return _tableName; }
        }
    }
}